| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" | 7 #include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" |
| 8 | 8 |
| 9 #include "xfa/fxfa/app/xfa_ffnotify.h" | 9 #include "xfa/fxfa/app/xfa_ffnotify.h" |
| 10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" | 10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
| 11 #include "xfa/fxfa/parser/xfa_doclayout.h" | 11 #include "xfa/fxfa/parser/xfa_doclayout.h" |
| 12 #include "xfa/fxfa/parser/xfa_document.h" | 12 #include "xfa/fxfa/parser/xfa_document.h" |
| 13 #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h" | 13 #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h" |
| 14 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" | 14 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" |
| 15 #include "xfa/fxfa/parser/xfa_layout_appadapter.h" | 15 #include "xfa/fxfa/parser/xfa_layout_appadapter.h" |
| 16 #include "xfa/fxfa/parser/xfa_layout_itemlayout.h" | 16 #include "xfa/fxfa/parser/xfa_layout_itemlayout.h" |
| 17 #include "xfa/fxfa/parser/xfa_localemgr.h" | 17 #include "xfa/fxfa/parser/xfa_localemgr.h" |
| 18 #include "xfa/fxfa/parser/xfa_object.h" | 18 #include "xfa/fxfa/parser/xfa_object.h" |
| 19 #include "xfa/fxfa/parser/xfa_parser.h" | 19 #include "xfa/fxfa/parser/xfa_parser.h" |
| 20 #include "xfa/fxfa/parser/xfa_parser_imp.h" | 20 #include "xfa/fxfa/parser/xfa_parser_imp.h" |
| 21 #include "xfa/fxfa/parser/xfa_script.h" | 21 #include "xfa/fxfa/parser/xfa_script.h" |
| 22 #include "xfa/fxfa/parser/xfa_script_imp.h" | 22 #include "xfa/fxfa/parser/xfa_script_imp.h" |
| 23 #include "xfa/fxfa/parser/xfa_utils.h" | 23 #include "xfa/fxfa/parser/xfa_utils.h" |
| 24 | 24 |
| 25 namespace { |
| 26 |
| 27 class PageSetContainerLayoutItem { |
| 28 public: |
| 29 static inline CXFA_ContainerLayoutItem* GetFirstChild( |
| 30 CXFA_ContainerLayoutItem* pLayoutItem) { |
| 31 if (pLayoutItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageSet) |
| 32 return nullptr; |
| 33 |
| 34 CXFA_ContainerLayoutItem* pChildItem = |
| 35 static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pFirstChild); |
| 36 while (pChildItem && |
| 37 pChildItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageSet) { |
| 38 pChildItem = |
| 39 static_cast<CXFA_ContainerLayoutItem*>(pChildItem->m_pNextSibling); |
| 40 } |
| 41 return pChildItem; |
| 42 } |
| 43 |
| 44 static inline CXFA_ContainerLayoutItem* GetNextSibling( |
| 45 CXFA_ContainerLayoutItem* pLayoutItem) { |
| 46 CXFA_ContainerLayoutItem* pChildItem = |
| 47 static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pNextSibling); |
| 48 while (pChildItem && |
| 49 pChildItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageSet) { |
| 50 pChildItem = |
| 51 static_cast<CXFA_ContainerLayoutItem*>(pChildItem->m_pNextSibling); |
| 52 } |
| 53 return pChildItem; |
| 54 } |
| 55 |
| 56 static inline CXFA_ContainerLayoutItem* GetParent( |
| 57 CXFA_ContainerLayoutItem* pLayoutItem) { |
| 58 return static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pParent); |
| 59 } |
| 60 }; |
| 61 |
| 62 uint32_t GetRelevant(CXFA_Node* pFormItem, uint32_t dwParentRelvant) { |
| 63 uint32_t dwRelevant = XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable; |
| 64 CFX_WideStringC wsRelevant; |
| 65 if (pFormItem->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant)) { |
| 66 if (wsRelevant == FX_WSTRC(L"+print") || wsRelevant == FX_WSTRC(L"print")) |
| 67 dwRelevant &= ~XFA_WidgetStatus_Viewable; |
| 68 else if (wsRelevant == FX_WSTRC(L"-print")) |
| 69 dwRelevant &= ~XFA_WidgetStatus_Printable; |
| 70 } |
| 71 if (!(dwParentRelvant & XFA_WidgetStatus_Viewable) && |
| 72 (dwRelevant != XFA_WidgetStatus_Viewable)) { |
| 73 dwRelevant &= ~XFA_WidgetStatus_Viewable; |
| 74 } |
| 75 if (!(dwParentRelvant & XFA_WidgetStatus_Printable) && |
| 76 (dwRelevant != XFA_WidgetStatus_Printable)) { |
| 77 dwRelevant &= ~XFA_WidgetStatus_Printable; |
| 78 } |
| 79 return dwRelevant; |
| 80 } |
| 81 |
| 82 void SyncContainer(CXFA_FFNotify* pNotify, |
| 83 CXFA_LayoutProcessor* pDocLayout, |
| 84 CXFA_LayoutItem* pContainerItem, |
| 85 uint32_t dwRelevant, |
| 86 FX_BOOL bVisible, |
| 87 int32_t nPageIndex) { |
| 88 FX_BOOL bVisibleItem = FALSE; |
| 89 uint32_t dwStatus = 0; |
| 90 uint32_t dwRelevantContainer = 0; |
| 91 if (bVisible) { |
| 92 XFA_ATTRIBUTEENUM eAttributeValue = |
| 93 pContainerItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence); |
| 94 if (eAttributeValue == XFA_ATTRIBUTEENUM_Visible || |
| 95 eAttributeValue == XFA_ATTRIBUTEENUM_Unknown) { |
| 96 bVisibleItem = TRUE; |
| 97 } |
| 98 dwRelevantContainer = GetRelevant(pContainerItem->m_pFormNode, dwRelevant); |
| 99 dwStatus = |
| 100 (bVisibleItem ? XFA_WidgetStatus_Visible : 0) | dwRelevantContainer; |
| 101 } |
| 102 pNotify->OnLayoutItemAdded(pDocLayout, pContainerItem, nPageIndex, dwStatus); |
| 103 for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild; |
| 104 pChild = pChild->m_pNextSibling) { |
| 105 if (pChild->IsContentLayoutItem()) { |
| 106 SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer, |
| 107 bVisibleItem, nPageIndex); |
| 108 } |
| 109 } |
| 110 } |
| 111 |
| 112 void ReorderLayoutItemToTail(CXFA_ContainerLayoutItem* pLayoutItem) { |
| 113 CXFA_ContainerLayoutItem* pParentLayoutItem = |
| 114 (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; |
| 115 if (!pParentLayoutItem) |
| 116 return; |
| 117 |
| 118 pParentLayoutItem->RemoveChild(pLayoutItem); |
| 119 pParentLayoutItem->AddChild(pLayoutItem); |
| 120 } |
| 121 |
| 122 void RemoveLayoutItem(CXFA_ContainerLayoutItem* pLayoutItem) { |
| 123 CXFA_ContainerLayoutItem* pParentLayoutItem = |
| 124 (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; |
| 125 if (!pParentLayoutItem) |
| 126 return; |
| 127 |
| 128 pParentLayoutItem->RemoveChild(pLayoutItem); |
| 129 } |
| 130 |
| 131 CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot, |
| 132 FX_BOOL bNewExprStyle, |
| 133 CFX_WideStringC& wsTargetExpr) { |
| 134 CXFA_Document* pDocument = pPageSetRoot->GetDocument(); |
| 135 if (wsTargetExpr.IsEmpty()) |
| 136 return nullptr; |
| 137 |
| 138 CFX_WideString wsTargetAll(wsTargetExpr); |
| 139 wsTargetAll.TrimLeft(); |
| 140 wsTargetAll.TrimRight(); |
| 141 int32_t iSpliteIndex = 0; |
| 142 FX_BOOL bTargetAllFind = TRUE; |
| 143 while (iSpliteIndex != -1) { |
| 144 CFX_WideString wsTargetExpr; |
| 145 int32_t iSpliteNextIndex = 0; |
| 146 if (!bTargetAllFind) { |
| 147 iSpliteNextIndex = wsTargetAll.Find(' ', iSpliteIndex); |
| 148 wsTargetExpr = |
| 149 wsTargetAll.Mid(iSpliteIndex, iSpliteNextIndex - iSpliteIndex); |
| 150 } else { |
| 151 wsTargetExpr = wsTargetAll; |
| 152 } |
| 153 if (wsTargetExpr.IsEmpty()) |
| 154 return nullptr; |
| 155 |
| 156 bTargetAllFind = FALSE; |
| 157 if (wsTargetExpr.GetAt(0) == '#') { |
| 158 CXFA_Node* pNode = pDocument->GetNodeByID( |
| 159 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Template)), |
| 160 wsTargetExpr.Mid(1).AsStringC()); |
| 161 if (pNode) |
| 162 return pNode; |
| 163 } else if (bNewExprStyle) { |
| 164 CFX_WideString wsProcessedTarget = wsTargetExpr; |
| 165 if (wsTargetExpr.Left(4) == FX_WSTRC(L"som(") && |
| 166 wsTargetExpr.Right(1) == FX_WSTRC(L")")) { |
| 167 wsProcessedTarget = wsTargetExpr.Mid(4, wsTargetExpr.GetLength() - 5); |
| 168 } |
| 169 XFA_RESOLVENODE_RS rs; |
| 170 int32_t iCount = pDocument->GetScriptContext()->ResolveObjects( |
| 171 pPageSetRoot, wsProcessedTarget.AsStringC(), rs, |
| 172 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | |
| 173 XFA_RESOLVENODE_Attributes | XFA_RESOLVENODE_Siblings | |
| 174 XFA_RESOLVENODE_Parent); |
| 175 if (iCount > 0 && rs.nodes[0]->IsNode()) |
| 176 return rs.nodes[0]->AsNode(); |
| 177 } |
| 178 iSpliteIndex = iSpliteNextIndex; |
| 179 } |
| 180 return nullptr; |
| 181 } |
| 182 |
| 183 void SetLayoutGeneratedNodeFlag(CXFA_Node* pNode) { |
| 184 pNode->SetFlag(XFA_NODEFLAG_LayoutGeneratedNode, false); |
| 185 pNode->ClearFlag(XFA_NODEFLAG_UnusedNode); |
| 186 } |
| 187 |
| 188 FX_BOOL CheckContentAreaNotUsed( |
| 189 CXFA_ContainerLayoutItem* pPageAreaLayoutItem, |
| 190 CXFA_Node* pContentArea, |
| 191 CXFA_ContainerLayoutItem*& pContentAreaLayoutItem) { |
| 192 for (CXFA_ContainerLayoutItem* pLayoutItem = |
| 193 (CXFA_ContainerLayoutItem*)pPageAreaLayoutItem->m_pFirstChild; |
| 194 pLayoutItem; |
| 195 pLayoutItem = (CXFA_ContainerLayoutItem*)pLayoutItem->m_pNextSibling) { |
| 196 if (pLayoutItem->m_pFormNode == pContentArea) { |
| 197 if (pLayoutItem->m_pFirstChild == NULL) { |
| 198 pContentAreaLayoutItem = pLayoutItem; |
| 199 return TRUE; |
| 200 } |
| 201 return FALSE; |
| 202 } |
| 203 } |
| 204 return TRUE; |
| 205 } |
| 206 |
| 207 void SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem, |
| 208 CXFA_FFNotify* pNotify, |
| 209 CXFA_LayoutProcessor* pDocLayout) { |
| 210 CXFA_LayoutItem* pNextLayoutItem; |
| 211 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; |
| 212 while (pCurLayoutItem) { |
| 213 pNextLayoutItem = pCurLayoutItem->m_pNextSibling; |
| 214 if (pCurLayoutItem->m_pFirstChild) |
| 215 SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); |
| 216 |
| 217 pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem); |
| 218 delete pCurLayoutItem; |
| 219 pCurLayoutItem = pNextLayoutItem; |
| 220 } |
| 221 } |
| 222 |
| 223 } // namespace |
| 224 |
| 25 CXFA_LayoutPageMgr::CXFA_LayoutPageMgr(CXFA_LayoutProcessor* pLayoutProcessor) | 225 CXFA_LayoutPageMgr::CXFA_LayoutPageMgr(CXFA_LayoutProcessor* pLayoutProcessor) |
| 26 : m_pLayoutProcessor(pLayoutProcessor), | 226 : m_pLayoutProcessor(pLayoutProcessor), |
| 27 m_pTemplatePageSetRoot(nullptr), | 227 m_pTemplatePageSetRoot(nullptr), |
| 28 m_pPageSetLayoutItemRoot(nullptr), | 228 m_pPageSetLayoutItemRoot(nullptr), |
| 29 m_pPageSetCurRoot(nullptr), | 229 m_pPageSetCurRoot(nullptr), |
| 30 m_pCurrentContainerRecord(nullptr), | 230 m_pCurrentContainerRecord(nullptr), |
| 31 m_pCurPageArea(nullptr), | 231 m_pCurPageArea(nullptr), |
| 32 m_nAvailPages(0), | 232 m_nAvailPages(0), |
| 33 m_nCurPageCount(0), | 233 m_nCurPageCount(0), |
| 34 m_ePageSetMode(XFA_ATTRIBUTEENUM_OrderedOccurrence), | 234 m_ePageSetMode(XFA_ATTRIBUTEENUM_OrderedOccurrence), |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 } | 372 } |
| 173 CXFA_Node* pPageNode = GetNextAvailPageArea(NULL); | 373 CXFA_Node* pPageNode = GetNextAvailPageArea(NULL); |
| 174 if (!pPageNode) { | 374 if (!pPageNode) { |
| 175 return FALSE; | 375 return FALSE; |
| 176 } | 376 } |
| 177 if (bFirstTemPage && m_pCurrentContainerRecord == NULL) { | 377 if (bFirstTemPage && m_pCurrentContainerRecord == NULL) { |
| 178 m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); | 378 m_pCurrentContainerRecord = m_rgProposedContainerRecord.GetHeadPosition(); |
| 179 } | 379 } |
| 180 return !bFirstTemPage || m_pCurrentContainerRecord; | 380 return !bFirstTemPage || m_pCurrentContainerRecord; |
| 181 } | 381 } |
| 182 static void XFA_LayoutItemMgr_ReorderLayoutItemToTail( | 382 |
| 183 CXFA_ContainerLayoutItem* pLayoutItem) { | |
| 184 CXFA_ContainerLayoutItem* pParentLayoutItem = | |
| 185 (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; | |
| 186 if (!pParentLayoutItem) { | |
| 187 return; | |
| 188 } | |
| 189 pParentLayoutItem->RemoveChild(pLayoutItem); | |
| 190 pParentLayoutItem->AddChild(pLayoutItem); | |
| 191 } | |
| 192 static void XFA_LayoutItemMgr_RemoveLayoutItem( | |
| 193 CXFA_ContainerLayoutItem* pLayoutItem) { | |
| 194 CXFA_ContainerLayoutItem* pParentLayoutItem = | |
| 195 (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; | |
| 196 if (!pParentLayoutItem) { | |
| 197 return; | |
| 198 } | |
| 199 pParentLayoutItem->RemoveChild(pLayoutItem); | |
| 200 } | |
| 201 void CXFA_LayoutPageMgr::RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord, | 383 void CXFA_LayoutPageMgr::RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord, |
| 202 CXFA_ContainerRecord* pPrevRecord) { | 384 CXFA_ContainerRecord* pPrevRecord) { |
| 203 if (!pNewRecord || !pPrevRecord) { | 385 if (!pNewRecord || !pPrevRecord) { |
| 204 return; | 386 return; |
| 205 } | 387 } |
| 206 if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) { | 388 if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) { |
| 207 XFA_LayoutItemMgr_RemoveLayoutItem(pNewRecord->pCurPageSet); | 389 RemoveLayoutItem(pNewRecord->pCurPageSet); |
| 208 return; | 390 return; |
| 209 } | 391 } |
| 210 if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) { | 392 if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) { |
| 211 XFA_LayoutItemMgr_RemoveLayoutItem(pNewRecord->pCurPageArea); | 393 RemoveLayoutItem(pNewRecord->pCurPageArea); |
| 212 return; | 394 return; |
| 213 } | 395 } |
| 214 if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) { | 396 if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) { |
| 215 XFA_LayoutItemMgr_RemoveLayoutItem(pNewRecord->pCurContentArea); | 397 RemoveLayoutItem(pNewRecord->pCurContentArea); |
| 216 return; | 398 return; |
| 217 } | 399 } |
| 218 } | 400 } |
| 219 void CXFA_LayoutPageMgr::ReorderPendingLayoutRecordToTail( | 401 void CXFA_LayoutPageMgr::ReorderPendingLayoutRecordToTail( |
| 220 CXFA_ContainerRecord* pNewRecord, | 402 CXFA_ContainerRecord* pNewRecord, |
| 221 CXFA_ContainerRecord* pPrevRecord) { | 403 CXFA_ContainerRecord* pPrevRecord) { |
| 222 if (!pNewRecord || !pPrevRecord) { | 404 if (!pNewRecord || !pPrevRecord) { |
| 223 return; | 405 return; |
| 224 } | 406 } |
| 225 if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) { | 407 if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) { |
| 226 XFA_LayoutItemMgr_ReorderLayoutItemToTail(pNewRecord->pCurPageSet); | 408 ReorderLayoutItemToTail(pNewRecord->pCurPageSet); |
| 227 return; | 409 return; |
| 228 } | 410 } |
| 229 if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) { | 411 if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) { |
| 230 XFA_LayoutItemMgr_ReorderLayoutItemToTail(pNewRecord->pCurPageArea); | 412 ReorderLayoutItemToTail(pNewRecord->pCurPageArea); |
| 231 return; | 413 return; |
| 232 } | 414 } |
| 233 if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) { | 415 if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) { |
| 234 XFA_LayoutItemMgr_ReorderLayoutItemToTail(pNewRecord->pCurContentArea); | 416 ReorderLayoutItemToTail(pNewRecord->pCurContentArea); |
| 235 return; | 417 return; |
| 236 } | 418 } |
| 237 } | 419 } |
| 238 void CXFA_LayoutPageMgr::SubmitContentItem( | 420 void CXFA_LayoutPageMgr::SubmitContentItem( |
| 239 CXFA_ContentLayoutItem* pContentLayoutItem, | 421 CXFA_ContentLayoutItem* pContentLayoutItem, |
| 240 XFA_ItemLayoutProcessorResult eStatus) { | 422 XFA_ItemLayoutProcessorResult eStatus) { |
| 241 if (pContentLayoutItem) { | 423 if (pContentLayoutItem) { |
| 242 GetCurrentContainerRecord()->pCurContentArea->AddChild(pContentLayoutItem); | 424 GetCurrentContainerRecord()->pCurContentArea->AddChild(pContentLayoutItem); |
| 243 m_bCreateOverFlowPage = FALSE; | 425 m_bCreateOverFlowPage = FALSE; |
| 244 } | 426 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 260 FX_FLOAT fAvailHeight = | 442 FX_FLOAT fAvailHeight = |
| 261 pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); | 443 pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); |
| 262 if (fAvailHeight >= XFA_LAYOUT_FLOAT_PERCISION) | 444 if (fAvailHeight >= XFA_LAYOUT_FLOAT_PERCISION) |
| 263 return fAvailHeight; | 445 return fAvailHeight; |
| 264 if (m_pCurrentContainerRecord == | 446 if (m_pCurrentContainerRecord == |
| 265 m_rgProposedContainerRecord.GetHeadPosition()) { | 447 m_rgProposedContainerRecord.GetHeadPosition()) { |
| 266 return 0.0f; | 448 return 0.0f; |
| 267 } | 449 } |
| 268 return XFA_LAYOUT_FLOAT_MAX; | 450 return XFA_LAYOUT_FLOAT_MAX; |
| 269 } | 451 } |
| 270 static CXFA_Node* XFA_ResolveBreakTarget(CXFA_Node* pPageSetRoot, | |
| 271 FX_BOOL bNewExprStyle, | |
| 272 CFX_WideStringC& wsTargetExpr) { | |
| 273 CXFA_Document* pDocument = pPageSetRoot->GetDocument(); | |
| 274 if (wsTargetExpr.IsEmpty()) { | |
| 275 return NULL; | |
| 276 } | |
| 277 CFX_WideString wsTargetAll(wsTargetExpr); | |
| 278 wsTargetAll.TrimLeft(); | |
| 279 wsTargetAll.TrimRight(); | |
| 280 int32_t iSpliteIndex = 0; | |
| 281 FX_BOOL bTargetAllFind = TRUE; | |
| 282 while (iSpliteIndex != -1) { | |
| 283 CFX_WideString wsTargetExpr; | |
| 284 int32_t iSpliteNextIndex = 0; | |
| 285 if (!bTargetAllFind) { | |
| 286 iSpliteNextIndex = wsTargetAll.Find(' ', iSpliteIndex); | |
| 287 wsTargetExpr = | |
| 288 wsTargetAll.Mid(iSpliteIndex, iSpliteNextIndex - iSpliteIndex); | |
| 289 } else { | |
| 290 wsTargetExpr = wsTargetAll; | |
| 291 } | |
| 292 if (wsTargetExpr.IsEmpty()) { | |
| 293 return NULL; | |
| 294 } | |
| 295 bTargetAllFind = FALSE; | |
| 296 if (wsTargetExpr.GetAt(0) == '#') { | |
| 297 CXFA_Node* pNode = pDocument->GetNodeByID( | |
| 298 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Template)), | |
| 299 wsTargetExpr.Mid(1).AsStringC()); | |
| 300 if (pNode) { | |
| 301 return pNode; | |
| 302 } | |
| 303 } else if (bNewExprStyle) { | |
| 304 CFX_WideString wsProcessedTarget = wsTargetExpr; | |
| 305 if (wsTargetExpr.Left(4) == FX_WSTRC(L"som(") && | |
| 306 wsTargetExpr.Right(1) == FX_WSTRC(L")")) { | |
| 307 wsProcessedTarget = wsTargetExpr.Mid(4, wsTargetExpr.GetLength() - 5); | |
| 308 } | |
| 309 XFA_RESOLVENODE_RS rs; | |
| 310 int32_t iCount = pDocument->GetScriptContext()->ResolveObjects( | |
| 311 pPageSetRoot, wsProcessedTarget.AsStringC(), rs, | |
| 312 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | | |
| 313 XFA_RESOLVENODE_Attributes | XFA_RESOLVENODE_Siblings | | |
| 314 XFA_RESOLVENODE_Parent); | |
| 315 if (iCount > 0 && rs.nodes[0]->IsNode()) { | |
| 316 return rs.nodes[0]->AsNode(); | |
| 317 } | |
| 318 } | |
| 319 iSpliteIndex = iSpliteNextIndex; | |
| 320 } | |
| 321 return NULL; | |
| 322 } | |
| 323 | 452 |
| 324 FX_BOOL XFA_LayoutPageMgr_RunBreakTestScript(CXFA_Node* pTestScript) { | 453 FX_BOOL XFA_LayoutPageMgr_RunBreakTestScript(CXFA_Node* pTestScript) { |
| 325 CFX_WideString wsExpression; | 454 CFX_WideString wsExpression; |
| 326 pTestScript->TryContent(wsExpression); | 455 pTestScript->TryContent(wsExpression); |
| 327 if (wsExpression.IsEmpty()) { | 456 if (wsExpression.IsEmpty()) { |
| 328 return TRUE; | 457 return TRUE; |
| 329 } | 458 } |
| 330 return pTestScript->GetDocument()->GetParser()->GetNotify()->RunScript( | 459 return pTestScript->GetDocument()->GetParser()->GetNotify()->RunScript( |
| 331 pTestScript, pTestScript->GetNodeItem(XFA_NODEITEM_Parent, | 460 pTestScript, pTestScript->GetNodeItem(XFA_NODEITEM_Parent, |
| 332 XFA_OBJECTTYPE_ContainerNode)); | 461 XFA_OBJECTTYPE_ContainerNode)); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 if (pContentArea == NULL) { | 556 if (pContentArea == NULL) { |
| 428 pNewRecord->pCurContentArea = NULL; | 557 pNewRecord->pCurContentArea = NULL; |
| 429 return; | 558 return; |
| 430 } | 559 } |
| 431 CXFA_ContainerLayoutItem* pNewContentAreaLayoutItem = | 560 CXFA_ContainerLayoutItem* pNewContentAreaLayoutItem = |
| 432 new CXFA_ContainerLayoutItem(pContentArea); | 561 new CXFA_ContainerLayoutItem(pContentArea); |
| 433 ASSERT(pNewRecord->pCurPageArea); | 562 ASSERT(pNewRecord->pCurPageArea); |
| 434 pNewRecord->pCurPageArea->AddChild(pNewContentAreaLayoutItem); | 563 pNewRecord->pCurPageArea->AddChild(pNewContentAreaLayoutItem); |
| 435 pNewRecord->pCurContentArea = pNewContentAreaLayoutItem; | 564 pNewRecord->pCurContentArea = pNewContentAreaLayoutItem; |
| 436 } | 565 } |
| 437 class CXFA_TraverseStrategy_PageSetContainerLayoutItem { | 566 |
| 438 public: | |
| 439 static inline CXFA_ContainerLayoutItem* GetFirstChild( | |
| 440 CXFA_ContainerLayoutItem* pLayoutItem) { | |
| 441 if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_PageSet) { | |
| 442 CXFA_ContainerLayoutItem* pChildItem = | |
| 443 (CXFA_ContainerLayoutItem*)pLayoutItem->m_pFirstChild; | |
| 444 while (pChildItem && | |
| 445 pChildItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageSet) { | |
| 446 pChildItem = (CXFA_ContainerLayoutItem*)pChildItem->m_pNextSibling; | |
| 447 } | |
| 448 return pChildItem; | |
| 449 } | |
| 450 return NULL; | |
| 451 } | |
| 452 static inline CXFA_ContainerLayoutItem* GetNextSibling( | |
| 453 CXFA_ContainerLayoutItem* pLayoutItem) { | |
| 454 CXFA_ContainerLayoutItem* pChildItem = | |
| 455 (CXFA_ContainerLayoutItem*)pLayoutItem->m_pNextSibling; | |
| 456 while (pChildItem && | |
| 457 pChildItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageSet) { | |
| 458 pChildItem = (CXFA_ContainerLayoutItem*)pChildItem->m_pNextSibling; | |
| 459 } | |
| 460 return pChildItem; | |
| 461 } | |
| 462 static inline CXFA_ContainerLayoutItem* GetParent( | |
| 463 CXFA_ContainerLayoutItem* pLayoutItem) { | |
| 464 return (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; | |
| 465 } | |
| 466 }; | |
| 467 void CXFA_LayoutPageMgr::FinishPaginatedPageSets() { | 567 void CXFA_LayoutPageMgr::FinishPaginatedPageSets() { |
| 468 CXFA_ContainerLayoutItem* pRootPageSetLayoutItem = m_pPageSetLayoutItemRoot; | 568 CXFA_ContainerLayoutItem* pRootPageSetLayoutItem = m_pPageSetLayoutItemRoot; |
| 469 for (; pRootPageSetLayoutItem; | 569 for (; pRootPageSetLayoutItem; |
| 470 pRootPageSetLayoutItem = | 570 pRootPageSetLayoutItem = |
| 471 (CXFA_ContainerLayoutItem*)pRootPageSetLayoutItem->m_pNextSibling) { | 571 (CXFA_ContainerLayoutItem*)pRootPageSetLayoutItem->m_pNextSibling) { |
| 472 CXFA_NodeIteratorTemplate<CXFA_ContainerLayoutItem, | 572 CXFA_NodeIteratorTemplate<CXFA_ContainerLayoutItem, |
| 473 CXFA_TraverseStrategy_PageSetContainerLayoutItem> | 573 PageSetContainerLayoutItem> |
| 474 sIterator(pRootPageSetLayoutItem); | 574 sIterator(pRootPageSetLayoutItem); |
| 475 for (CXFA_ContainerLayoutItem* pPageSetLayoutItem = sIterator.GetCurrent(); | 575 for (CXFA_ContainerLayoutItem* pPageSetLayoutItem = sIterator.GetCurrent(); |
| 476 pPageSetLayoutItem; pPageSetLayoutItem = sIterator.MoveToNext()) { | 576 pPageSetLayoutItem; pPageSetLayoutItem = sIterator.MoveToNext()) { |
| 477 XFA_ATTRIBUTEENUM ePageRelation = | 577 XFA_ATTRIBUTEENUM ePageRelation = |
| 478 pPageSetLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Relation); | 578 pPageSetLayoutItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Relation); |
| 479 switch (ePageRelation) { | 579 switch (ePageRelation) { |
| 480 case XFA_ATTRIBUTEENUM_OrderedOccurrence: | 580 case XFA_ATTRIBUTEENUM_OrderedOccurrence: |
| 481 default: { ProcessLastPageSet(); } break; | 581 default: { ProcessLastPageSet(); } break; |
| 482 case XFA_ATTRIBUTEENUM_SimplexPaginated: | 582 case XFA_ATTRIBUTEENUM_SimplexPaginated: |
| 483 case XFA_ATTRIBUTEENUM_DuplexPaginated: { | 583 case XFA_ATTRIBUTEENUM_DuplexPaginated: { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode || | 740 pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode || |
| 641 bStartNew) { | 741 bStartNew) { |
| 642 CXFA_Node* pPageArea = GetNextAvailPageArea(pTarget, NULL, TRUE); | 742 CXFA_Node* pPageArea = GetNextAvailPageArea(pTarget, NULL, TRUE); |
| 643 bRet = pPageArea != NULL; | 743 bRet = pPageArea != NULL; |
| 644 } | 744 } |
| 645 break; | 745 break; |
| 646 case XFA_ATTRIBUTEENUM_PageOdd: | 746 case XFA_ATTRIBUTEENUM_PageOdd: |
| 647 if (pTarget && pTarget->GetClassID() != XFA_ELEMENT_PageArea) { | 747 if (pTarget && pTarget->GetClassID() != XFA_ELEMENT_PageArea) { |
| 648 pTarget = NULL; | 748 pTarget = NULL; |
| 649 } | 749 } |
| 650 if (m_nAvailPages % 2 != 1 || !m_pCurrentContainerRecord || | |
| 651 (pTarget && | |
| 652 pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode) || | |
| 653 bStartNew) { | |
| 654 if (m_nAvailPages % 2 == 1) { | |
| 655 } | |
| 656 } | |
| 657 break; | 750 break; |
| 658 case XFA_ATTRIBUTEENUM_PageEven: | 751 case XFA_ATTRIBUTEENUM_PageEven: |
| 659 if (pTarget && pTarget->GetClassID() != XFA_ELEMENT_PageArea) { | 752 if (pTarget && pTarget->GetClassID() != XFA_ELEMENT_PageArea) { |
| 660 pTarget = NULL; | 753 pTarget = NULL; |
| 661 } | 754 } |
| 662 if (m_nAvailPages % 2 != 0 || !m_pCurrentContainerRecord || | |
| 663 (pTarget && | |
| 664 pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode) || | |
| 665 bStartNew) { | |
| 666 if (m_nAvailPages % 2 == 0) { | |
| 667 } | |
| 668 } | |
| 669 break; | 755 break; |
| 670 case XFA_ATTRIBUTEENUM_Auto: | 756 case XFA_ATTRIBUTEENUM_Auto: |
| 671 default: | 757 default: |
| 672 break; | 758 break; |
| 673 } | 759 } |
| 674 return bRet; | 760 return bRet; |
| 675 } | 761 } |
| 676 FX_BOOL CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter( | 762 FX_BOOL CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter( |
| 677 CXFA_Node* pCurNode, | 763 CXFA_Node* pCurNode, |
| 678 FX_BOOL bBefore, | 764 FX_BOOL bBefore, |
| 679 CXFA_Node*& pBreakLeaderTemplate, | 765 CXFA_Node*& pBreakLeaderTemplate, |
| 680 CXFA_Node*& pBreakTrailerTemplate) { | 766 CXFA_Node*& pBreakTrailerTemplate) { |
| 681 XFA_ELEMENT eType = pCurNode->GetClassID(); | 767 XFA_ELEMENT eType = pCurNode->GetClassID(); |
| 682 switch (eType) { | 768 switch (eType) { |
| 683 case XFA_ELEMENT_BreakBefore: | 769 case XFA_ELEMENT_BreakBefore: |
| 684 case XFA_ELEMENT_BreakAfter: { | 770 case XFA_ELEMENT_BreakAfter: { |
| 685 CFX_WideStringC wsBreakLeader, wsBreakTrailer; | 771 CFX_WideStringC wsBreakLeader, wsBreakTrailer; |
| 686 CXFA_Node* pFormNode = pCurNode->GetNodeItem( | 772 CXFA_Node* pFormNode = pCurNode->GetNodeItem( |
| 687 XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); | 773 XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); |
| 688 CXFA_Node* pContainer = pFormNode->GetTemplateNode(); | 774 CXFA_Node* pContainer = pFormNode->GetTemplateNode(); |
| 689 FX_BOOL bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0; | 775 FX_BOOL bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0; |
| 690 CXFA_Node* pScript = pCurNode->GetFirstChildByClass(XFA_ELEMENT_Script); | 776 CXFA_Node* pScript = pCurNode->GetFirstChildByClass(XFA_ELEMENT_Script); |
| 691 if (pScript && !XFA_LayoutPageMgr_RunBreakTestScript(pScript)) { | 777 if (pScript && !XFA_LayoutPageMgr_RunBreakTestScript(pScript)) { |
| 692 return FALSE; | 778 return FALSE; |
| 693 } | 779 } |
| 694 CFX_WideStringC wsTarget = pCurNode->GetCData(XFA_ATTRIBUTE_Target); | 780 CFX_WideStringC wsTarget = pCurNode->GetCData(XFA_ATTRIBUTE_Target); |
| 695 CXFA_Node* pTarget = | 781 CXFA_Node* pTarget = |
| 696 XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); | 782 ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); |
| 697 wsBreakTrailer = pCurNode->GetCData(XFA_ATTRIBUTE_Trailer); | 783 wsBreakTrailer = pCurNode->GetCData(XFA_ATTRIBUTE_Trailer); |
| 698 wsBreakLeader = pCurNode->GetCData(XFA_ATTRIBUTE_Leader); | 784 wsBreakLeader = pCurNode->GetCData(XFA_ATTRIBUTE_Leader); |
| 699 pBreakLeaderTemplate = | 785 pBreakLeaderTemplate = |
| 700 XFA_ResolveBreakTarget(pContainer, TRUE, wsBreakLeader); | 786 ResolveBreakTarget(pContainer, TRUE, wsBreakLeader); |
| 701 pBreakTrailerTemplate = | 787 pBreakTrailerTemplate = |
| 702 XFA_ResolveBreakTarget(pContainer, TRUE, wsBreakTrailer); | 788 ResolveBreakTarget(pContainer, TRUE, wsBreakTrailer); |
| 703 if (RunBreak(eType, pCurNode->GetEnum(XFA_ATTRIBUTE_TargetType), pTarget, | 789 if (RunBreak(eType, pCurNode->GetEnum(XFA_ATTRIBUTE_TargetType), pTarget, |
| 704 bStartNew)) { | 790 bStartNew)) { |
| 705 return TRUE; | 791 return TRUE; |
| 706 } else { | 792 } else { |
| 707 if (m_rgProposedContainerRecord.GetCount() > 0 && | 793 if (m_rgProposedContainerRecord.GetCount() > 0 && |
| 708 m_pCurrentContainerRecord == | 794 m_pCurrentContainerRecord == |
| 709 m_rgProposedContainerRecord.GetHeadPosition() && | 795 m_rgProposedContainerRecord.GetHeadPosition() && |
| 710 eType == XFA_ELEMENT_BreakBefore) { | 796 eType == XFA_ELEMENT_BreakBefore) { |
| 711 CXFA_Node* pParentNode = pFormNode->GetNodeItem( | 797 CXFA_Node* pParentNode = pFormNode->GetNodeItem( |
| 712 XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); | 798 XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); |
| 713 if (!pParentNode || | 799 if (!pParentNode || |
| 714 pFormNode != | 800 pFormNode != |
| 715 pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild, | 801 pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild, |
| 716 XFA_OBJECTTYPE_ContainerNode)) { | 802 XFA_OBJECTTYPE_ContainerNode)) { |
| 717 break; | 803 break; |
| 718 } | 804 } |
| 719 pParentNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent); | 805 pParentNode = pParentNode->GetNodeItem(XFA_NODEITEM_Parent); |
| 720 if (!pParentNode || pParentNode->GetClassID() != XFA_ELEMENT_Form) { | 806 if (!pParentNode || pParentNode->GetClassID() != XFA_ELEMENT_Form) { |
| 721 break; | 807 break; |
| 722 } | 808 } |
| 723 return TRUE; | 809 return TRUE; |
| 724 } | 810 } |
| 725 } | 811 } |
| 726 } break; | 812 } break; |
| 727 case XFA_ELEMENT_Break: { | 813 case XFA_ELEMENT_Break: { |
| 728 FX_BOOL bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0; | 814 FX_BOOL bStartNew = pCurNode->GetInteger(XFA_ATTRIBUTE_StartNew) != 0; |
| 729 CFX_WideStringC wsTarget = pCurNode->GetCData( | 815 CFX_WideStringC wsTarget = pCurNode->GetCData( |
| 730 bBefore ? XFA_ATTRIBUTE_BeforeTarget : XFA_ATTRIBUTE_AfterTarget); | 816 bBefore ? XFA_ATTRIBUTE_BeforeTarget : XFA_ATTRIBUTE_AfterTarget); |
| 731 CXFA_Node* pTarget = | 817 CXFA_Node* pTarget = |
| 732 XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); | 818 ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); |
| 733 if (RunBreak(bBefore ? XFA_ELEMENT_BreakBefore : XFA_ELEMENT_BreakAfter, | 819 if (RunBreak(bBefore ? XFA_ELEMENT_BreakBefore : XFA_ELEMENT_BreakAfter, |
| 734 pCurNode->GetEnum(bBefore ? XFA_ATTRIBUTE_Before | 820 pCurNode->GetEnum(bBefore ? XFA_ATTRIBUTE_Before |
| 735 : XFA_ATTRIBUTE_After), | 821 : XFA_ATTRIBUTE_After), |
| 736 pTarget, bStartNew)) { | 822 pTarget, bStartNew)) { |
| 737 return TRUE; | 823 return TRUE; |
| 738 } | 824 } |
| 739 } break; | 825 } break; |
| 740 default: | 826 default: |
| 741 break; | 827 break; |
| 742 } | 828 } |
| 743 return FALSE; | 829 return FALSE; |
| 744 } | 830 } |
| 745 static void XFA_SetLayoutGeneratedNodeFlag(CXFA_Node* pNode) { | 831 |
| 746 pNode->SetFlag(XFA_NODEFLAG_LayoutGeneratedNode, false); | |
| 747 pNode->ClearFlag(XFA_NODEFLAG_UnusedNode); | |
| 748 } | |
| 749 FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter( | 832 FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter( |
| 750 CXFA_Node* pBreakNode, | 833 CXFA_Node* pBreakNode, |
| 751 FX_BOOL bBefore, | 834 FX_BOOL bBefore, |
| 752 CXFA_Node*& pBreakLeaderNode, | 835 CXFA_Node*& pBreakLeaderNode, |
| 753 CXFA_Node*& pBreakTrailerNode, | 836 CXFA_Node*& pBreakTrailerNode, |
| 754 FX_BOOL& bCreatePage) { | 837 FX_BOOL& bCreatePage) { |
| 755 CXFA_Node *pLeaderTemplate = NULL, *pTrailerTemplate = NULL; | 838 CXFA_Node *pLeaderTemplate = NULL, *pTrailerTemplate = NULL; |
| 756 CXFA_Node* pFormNode = pBreakNode->GetNodeItem(XFA_NODEITEM_Parent, | 839 CXFA_Node* pFormNode = pBreakNode->GetNodeItem(XFA_NODEITEM_Parent, |
| 757 XFA_OBJECTTYPE_ContainerNode); | 840 XFA_OBJECTTYPE_ContainerNode); |
| 758 if (XFA_ItemLayoutProcessor_IsTakingSpace(pFormNode)) { | 841 if (XFA_ItemLayoutProcessor_IsTakingSpace(pFormNode)) { |
| 759 bCreatePage = ExecuteBreakBeforeOrAfter(pBreakNode, bBefore, | 842 bCreatePage = ExecuteBreakBeforeOrAfter(pBreakNode, bBefore, |
| 760 pLeaderTemplate, pTrailerTemplate); | 843 pLeaderTemplate, pTrailerTemplate); |
| 761 CXFA_Document* pDocument = pBreakNode->GetDocument(); | 844 CXFA_Document* pDocument = pBreakNode->GetDocument(); |
| 762 CXFA_Node* pDataScope = NULL; | 845 CXFA_Node* pDataScope = NULL; |
| 763 pFormNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent, | 846 pFormNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent, |
| 764 XFA_OBJECTTYPE_ContainerNode); | 847 XFA_OBJECTTYPE_ContainerNode); |
| 765 if (pLeaderTemplate) { | 848 if (pLeaderTemplate) { |
| 766 if (!pDataScope) { | 849 if (!pDataScope) { |
| 767 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); | 850 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); |
| 768 } | 851 } |
| 769 pBreakLeaderNode = pDocument->DataMerge_CopyContainer( | 852 pBreakLeaderNode = pDocument->DataMerge_CopyContainer( |
| 770 pLeaderTemplate, pFormNode, pDataScope, TRUE); | 853 pLeaderTemplate, pFormNode, pDataScope, TRUE); |
| 771 pDocument->DataMerge_UpdateBindingRelations(pBreakLeaderNode); | 854 pDocument->DataMerge_UpdateBindingRelations(pBreakLeaderNode); |
| 772 XFA_SetLayoutGeneratedNodeFlag(pBreakLeaderNode); | 855 SetLayoutGeneratedNodeFlag(pBreakLeaderNode); |
| 773 } | 856 } |
| 774 if (pTrailerTemplate) { | 857 if (pTrailerTemplate) { |
| 775 if (!pDataScope) { | 858 if (!pDataScope) { |
| 776 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); | 859 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); |
| 777 } | 860 } |
| 778 pBreakTrailerNode = pDocument->DataMerge_CopyContainer( | 861 pBreakTrailerNode = pDocument->DataMerge_CopyContainer( |
| 779 pTrailerTemplate, pFormNode, pDataScope, TRUE); | 862 pTrailerTemplate, pFormNode, pDataScope, TRUE); |
| 780 pDocument->DataMerge_UpdateBindingRelations(pBreakTrailerNode); | 863 pDocument->DataMerge_UpdateBindingRelations(pBreakTrailerNode); |
| 781 XFA_SetLayoutGeneratedNodeFlag(pBreakTrailerNode); | 864 SetLayoutGeneratedNodeFlag(pBreakTrailerNode); |
| 782 } | 865 } |
| 783 return TRUE; | 866 return TRUE; |
| 784 } | 867 } |
| 785 return FALSE; | 868 return FALSE; |
| 786 } | 869 } |
| 787 FX_BOOL CXFA_LayoutPageMgr::ProcessBookendLeaderOrTrailer( | 870 FX_BOOL CXFA_LayoutPageMgr::ProcessBookendLeaderOrTrailer( |
| 788 CXFA_Node* pBookendNode, | 871 CXFA_Node* pBookendNode, |
| 789 FX_BOOL bLeader, | 872 FX_BOOL bLeader, |
| 790 CXFA_Node*& pBookendAppendNode) { | 873 CXFA_Node*& pBookendAppendNode) { |
| 791 CXFA_Node* pLeaderTemplate = NULL; | 874 CXFA_Node* pLeaderTemplate = NULL; |
| 792 CXFA_Node* pFormNode = pBookendNode->GetNodeItem( | 875 CXFA_Node* pFormNode = pBookendNode->GetNodeItem( |
| 793 XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); | 876 XFA_NODEITEM_Parent, XFA_OBJECTTYPE_ContainerNode); |
| 794 if (ResolveBookendLeaderOrTrailer(pBookendNode, bLeader, pLeaderTemplate)) { | 877 if (ResolveBookendLeaderOrTrailer(pBookendNode, bLeader, pLeaderTemplate)) { |
| 795 CXFA_Document* pDocument = pBookendNode->GetDocument(); | 878 CXFA_Document* pDocument = pBookendNode->GetDocument(); |
| 796 CXFA_Node* pDataScope = NULL; | 879 CXFA_Node* pDataScope = NULL; |
| 797 if (pLeaderTemplate) { | 880 if (pLeaderTemplate) { |
| 798 if (!pDataScope) { | 881 if (!pDataScope) { |
| 799 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); | 882 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); |
| 800 } | 883 } |
| 801 pBookendAppendNode = pDocument->DataMerge_CopyContainer( | 884 pBookendAppendNode = pDocument->DataMerge_CopyContainer( |
| 802 pLeaderTemplate, pFormNode, pDataScope, TRUE); | 885 pLeaderTemplate, pFormNode, pDataScope, TRUE); |
| 803 pDocument->DataMerge_UpdateBindingRelations(pBookendAppendNode); | 886 pDocument->DataMerge_UpdateBindingRelations(pBookendAppendNode); |
| 804 XFA_SetLayoutGeneratedNodeFlag(pBookendAppendNode); | 887 SetLayoutGeneratedNodeFlag(pBookendAppendNode); |
| 805 return TRUE; | 888 return TRUE; |
| 806 } | 889 } |
| 807 } | 890 } |
| 808 return FALSE; | 891 return FALSE; |
| 809 } | 892 } |
| 810 CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode, | 893 CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode, |
| 811 CXFA_Node*& pLeaderTemplate, | 894 CXFA_Node*& pLeaderTemplate, |
| 812 CXFA_Node*& pTrailerTemplate, | 895 CXFA_Node*& pTrailerTemplate, |
| 813 FX_BOOL bCreatePage) { | 896 FX_BOOL bCreatePage) { |
| 814 CFX_WideStringC wsOverflowLeader, wsOverflowTrailer; | 897 CFX_WideStringC wsOverflowLeader, wsOverflowTrailer; |
| 815 CXFA_Node* pContainer = | 898 CXFA_Node* pContainer = |
| 816 pOverflowNode->GetNodeItem(XFA_NODEITEM_Parent, | 899 pOverflowNode->GetNodeItem(XFA_NODEITEM_Parent, |
| 817 XFA_OBJECTTYPE_ContainerNode) | 900 XFA_OBJECTTYPE_ContainerNode) |
| 818 ->GetTemplateNode(); | 901 ->GetTemplateNode(); |
| 819 if (pOverflowNode->GetClassID() == XFA_ELEMENT_Break) { | 902 if (pOverflowNode->GetClassID() == XFA_ELEMENT_Break) { |
| 820 CFX_WideStringC wsOverflowLeader; | 903 CFX_WideStringC wsOverflowLeader; |
| 821 CFX_WideStringC wsOverflowTarget; | 904 CFX_WideStringC wsOverflowTarget; |
| 822 CFX_WideStringC wsOverflowTrailer; | 905 CFX_WideStringC wsOverflowTrailer; |
| 823 pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowLeader, wsOverflowLeader); | 906 pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowLeader, wsOverflowLeader); |
| 824 pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowTrailer, wsOverflowTrailer); | 907 pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowTrailer, wsOverflowTrailer); |
| 825 pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowTarget, wsOverflowTarget); | 908 pOverflowNode->TryCData(XFA_ATTRIBUTE_OverflowTarget, wsOverflowTarget); |
| 826 if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() || | 909 if (!wsOverflowLeader.IsEmpty() || !wsOverflowTrailer.IsEmpty() || |
| 827 !wsOverflowTarget.IsEmpty()) { | 910 !wsOverflowTarget.IsEmpty()) { |
| 828 if (!wsOverflowTarget.IsEmpty() && bCreatePage && | 911 if (!wsOverflowTarget.IsEmpty() && bCreatePage && |
| 829 !m_bCreateOverFlowPage) { | 912 !m_bCreateOverFlowPage) { |
| 830 CXFA_Node* pTarget = XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, | 913 CXFA_Node* pTarget = |
| 831 TRUE, wsOverflowTarget); | 914 ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsOverflowTarget); |
| 832 if (pTarget) { | 915 if (pTarget) { |
| 833 m_bCreateOverFlowPage = TRUE; | 916 m_bCreateOverFlowPage = TRUE; |
| 834 switch (pTarget->GetClassID()) { | 917 switch (pTarget->GetClassID()) { |
| 835 case XFA_ELEMENT_PageArea: | 918 case XFA_ELEMENT_PageArea: |
| 836 RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_PageArea, | 919 RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_PageArea, |
| 837 pTarget, TRUE); | 920 pTarget, TRUE); |
| 838 break; | 921 break; |
| 839 case XFA_ELEMENT_ContentArea: | 922 case XFA_ELEMENT_ContentArea: |
| 840 RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_ContentArea, | 923 RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_ContentArea, |
| 841 pTarget, TRUE); | 924 pTarget, TRUE); |
| 842 break; | 925 break; |
| 843 default: | 926 default: |
| 844 break; | 927 break; |
| 845 } | 928 } |
| 846 } | 929 } |
| 847 } | 930 } |
| 848 if (!bCreatePage) { | 931 if (!bCreatePage) { |
| 849 pLeaderTemplate = | 932 pLeaderTemplate = |
| 850 XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); | 933 ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); |
| 851 pTrailerTemplate = | 934 pTrailerTemplate = |
| 852 XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); | 935 ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); |
| 853 } | 936 } |
| 854 return pOverflowNode; | 937 return pOverflowNode; |
| 855 } | 938 } |
| 856 return NULL; | 939 return NULL; |
| 857 } else if (pOverflowNode->GetClassID() == XFA_ELEMENT_Overflow) { | 940 } else if (pOverflowNode->GetClassID() == XFA_ELEMENT_Overflow) { |
| 858 CFX_WideStringC wsOverflowTarget; | 941 CFX_WideStringC wsOverflowTarget; |
| 859 pOverflowNode->TryCData(XFA_ATTRIBUTE_Leader, wsOverflowLeader); | 942 pOverflowNode->TryCData(XFA_ATTRIBUTE_Leader, wsOverflowLeader); |
| 860 pOverflowNode->TryCData(XFA_ATTRIBUTE_Trailer, wsOverflowTrailer); | 943 pOverflowNode->TryCData(XFA_ATTRIBUTE_Trailer, wsOverflowTrailer); |
| 861 pOverflowNode->TryCData(XFA_ATTRIBUTE_Target, wsOverflowTarget); | 944 pOverflowNode->TryCData(XFA_ATTRIBUTE_Target, wsOverflowTarget); |
| 862 if (!wsOverflowTarget.IsEmpty() && bCreatePage && !m_bCreateOverFlowPage) { | 945 if (!wsOverflowTarget.IsEmpty() && bCreatePage && !m_bCreateOverFlowPage) { |
| 863 CXFA_Node* pTarget = XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, | 946 CXFA_Node* pTarget = |
| 864 wsOverflowTarget); | 947 ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsOverflowTarget); |
| 865 if (pTarget) { | 948 if (pTarget) { |
| 866 m_bCreateOverFlowPage = TRUE; | 949 m_bCreateOverFlowPage = TRUE; |
| 867 switch (pTarget->GetClassID()) { | 950 switch (pTarget->GetClassID()) { |
| 868 case XFA_ELEMENT_PageArea: | 951 case XFA_ELEMENT_PageArea: |
| 869 RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_PageArea, pTarget, | 952 RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_PageArea, pTarget, |
| 870 TRUE); | 953 TRUE); |
| 871 break; | 954 break; |
| 872 case XFA_ELEMENT_ContentArea: | 955 case XFA_ELEMENT_ContentArea: |
| 873 RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_ContentArea, | 956 RunBreak(XFA_ELEMENT_Overflow, XFA_ATTRIBUTEENUM_ContentArea, |
| 874 pTarget, TRUE); | 957 pTarget, TRUE); |
| 875 break; | 958 break; |
| 876 default: | 959 default: |
| 877 break; | 960 break; |
| 878 } | 961 } |
| 879 } | 962 } |
| 880 } | 963 } |
| 881 if (!bCreatePage) { | 964 if (!bCreatePage) { |
| 882 pLeaderTemplate = | 965 pLeaderTemplate = ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); |
| 883 XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); | |
| 884 pTrailerTemplate = | 966 pTrailerTemplate = |
| 885 XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); | 967 ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); |
| 886 } | 968 } |
| 887 return pOverflowNode; | 969 return pOverflowNode; |
| 888 } | 970 } |
| 889 return NULL; | 971 return NULL; |
| 890 } | 972 } |
| 891 FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode, | 973 FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode, |
| 892 CXFA_Node*& pLeaderNode, | 974 CXFA_Node*& pLeaderNode, |
| 893 CXFA_Node*& pTrailerNode, | 975 CXFA_Node*& pTrailerNode, |
| 894 FX_BOOL bDataMerge, | 976 FX_BOOL bDataMerge, |
| 895 FX_BOOL bCreatePage) { | 977 FX_BOOL bCreatePage) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 913 } | 995 } |
| 914 CXFA_Document* pDocument = pCurNode->GetDocument(); | 996 CXFA_Document* pDocument = pCurNode->GetDocument(); |
| 915 CXFA_Node* pDataScope = NULL; | 997 CXFA_Node* pDataScope = NULL; |
| 916 if (pLeaderTemplate) { | 998 if (pLeaderTemplate) { |
| 917 if (!pDataScope) { | 999 if (!pDataScope) { |
| 918 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); | 1000 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); |
| 919 } | 1001 } |
| 920 pLeaderNode = pDocument->DataMerge_CopyContainer( | 1002 pLeaderNode = pDocument->DataMerge_CopyContainer( |
| 921 pLeaderTemplate, pFormNode, pDataScope, TRUE); | 1003 pLeaderTemplate, pFormNode, pDataScope, TRUE); |
| 922 pDocument->DataMerge_UpdateBindingRelations(pLeaderNode); | 1004 pDocument->DataMerge_UpdateBindingRelations(pLeaderNode); |
| 923 XFA_SetLayoutGeneratedNodeFlag(pLeaderNode); | 1005 SetLayoutGeneratedNodeFlag(pLeaderNode); |
| 924 } | 1006 } |
| 925 if (pTrailerTemplate) { | 1007 if (pTrailerTemplate) { |
| 926 if (!pDataScope) { | 1008 if (!pDataScope) { |
| 927 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); | 1009 pDataScope = XFA_DataMerge_FindDataScope(pFormNode); |
| 928 } | 1010 } |
| 929 pTrailerNode = pDocument->DataMerge_CopyContainer( | 1011 pTrailerNode = pDocument->DataMerge_CopyContainer( |
| 930 pTrailerTemplate, pFormNode, pDataScope, TRUE); | 1012 pTrailerTemplate, pFormNode, pDataScope, TRUE); |
| 931 pDocument->DataMerge_UpdateBindingRelations(pTrailerNode); | 1013 pDocument->DataMerge_UpdateBindingRelations(pTrailerNode); |
| 932 XFA_SetLayoutGeneratedNodeFlag(pTrailerNode); | 1014 SetLayoutGeneratedNodeFlag(pTrailerNode); |
| 933 } | 1015 } |
| 934 return TRUE; | 1016 return TRUE; |
| 935 } | 1017 } |
| 936 if (bIsOverflowNode) { | 1018 if (bIsOverflowNode) { |
| 937 break; | 1019 break; |
| 938 } | 1020 } |
| 939 } | 1021 } |
| 940 return FALSE; | 1022 return FALSE; |
| 941 } | 1023 } |
| 942 FX_BOOL CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer( | 1024 FX_BOOL CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer( |
| 943 CXFA_Node* pBookendNode, | 1025 CXFA_Node* pBookendNode, |
| 944 FX_BOOL bLeader, | 1026 FX_BOOL bLeader, |
| 945 CXFA_Node*& pBookendAppendTemplate) { | 1027 CXFA_Node*& pBookendAppendTemplate) { |
| 946 CFX_WideStringC wsBookendLeader; | 1028 CFX_WideStringC wsBookendLeader; |
| 947 CXFA_Node* pContainer = | 1029 CXFA_Node* pContainer = |
| 948 pBookendNode->GetNodeItem(XFA_NODEITEM_Parent, | 1030 pBookendNode->GetNodeItem(XFA_NODEITEM_Parent, |
| 949 XFA_OBJECTTYPE_ContainerNode) | 1031 XFA_OBJECTTYPE_ContainerNode) |
| 950 ->GetTemplateNode(); | 1032 ->GetTemplateNode(); |
| 951 if (pBookendNode->GetClassID() == XFA_ELEMENT_Break) { | 1033 if (pBookendNode->GetClassID() == XFA_ELEMENT_Break) { |
| 952 pBookendNode->TryCData( | 1034 pBookendNode->TryCData( |
| 953 bLeader ? XFA_ATTRIBUTE_BookendLeader : XFA_ATTRIBUTE_BookendTrailer, | 1035 bLeader ? XFA_ATTRIBUTE_BookendLeader : XFA_ATTRIBUTE_BookendTrailer, |
| 954 wsBookendLeader); | 1036 wsBookendLeader); |
| 955 if (!wsBookendLeader.IsEmpty()) { | 1037 if (!wsBookendLeader.IsEmpty()) { |
| 956 pBookendAppendTemplate = | 1038 pBookendAppendTemplate = |
| 957 XFA_ResolveBreakTarget(pContainer, FALSE, wsBookendLeader); | 1039 ResolveBreakTarget(pContainer, FALSE, wsBookendLeader); |
| 958 return TRUE; | 1040 return TRUE; |
| 959 } | 1041 } |
| 960 return FALSE; | 1042 return FALSE; |
| 961 } else if (pBookendNode->GetClassID() == XFA_ELEMENT_Bookend) { | 1043 } else if (pBookendNode->GetClassID() == XFA_ELEMENT_Bookend) { |
| 962 pBookendNode->TryCData( | 1044 pBookendNode->TryCData( |
| 963 bLeader ? XFA_ATTRIBUTE_Leader : XFA_ATTRIBUTE_Trailer, | 1045 bLeader ? XFA_ATTRIBUTE_Leader : XFA_ATTRIBUTE_Trailer, |
| 964 wsBookendLeader); | 1046 wsBookendLeader); |
| 965 pBookendAppendTemplate = | 1047 pBookendAppendTemplate = |
| 966 XFA_ResolveBreakTarget(pContainer, TRUE, wsBookendLeader); | 1048 ResolveBreakTarget(pContainer, TRUE, wsBookendLeader); |
| 967 return TRUE; | 1049 return TRUE; |
| 968 } | 1050 } |
| 969 return FALSE; | 1051 return FALSE; |
| 970 } | 1052 } |
| 971 FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet( | 1053 FX_BOOL CXFA_LayoutPageMgr::FindPageAreaFromPageSet( |
| 972 CXFA_Node* pPageSet, | 1054 CXFA_Node* pPageSet, |
| 973 CXFA_Node* pStartChild, | 1055 CXFA_Node* pStartChild, |
| 974 CXFA_Node* pTargetPageArea, | 1056 CXFA_Node* pTargetPageArea, |
| 975 CXFA_Node* pTargetContentArea, | 1057 CXFA_Node* pTargetContentArea, |
| 976 FX_BOOL bNewPage, | 1058 FX_BOOL bNewPage, |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 pTargetContentArea, bNewPage, bQuery)) { | 1326 pTargetContentArea, bNewPage, bQuery)) { |
| 1245 return m_pCurPageArea; | 1327 return m_pCurPageArea; |
| 1246 } | 1328 } |
| 1247 if (pPageSet == m_pTemplatePageSetRoot) { | 1329 if (pPageSet == m_pTemplatePageSetRoot) { |
| 1248 break; | 1330 break; |
| 1249 } | 1331 } |
| 1250 pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); | 1332 pPageSet = pPageSet->GetNodeItem(XFA_NODEITEM_Parent); |
| 1251 } | 1333 } |
| 1252 return NULL; | 1334 return NULL; |
| 1253 } | 1335 } |
| 1254 static FX_BOOL XFA_LayoutPageMgr_CheckContentAreaNotUsed( | 1336 |
| 1255 CXFA_ContainerLayoutItem* pPageAreaLayoutItem, | |
| 1256 CXFA_Node* pContentArea, | |
| 1257 CXFA_ContainerLayoutItem*& pContentAreaLayoutItem) { | |
| 1258 for (CXFA_ContainerLayoutItem* pLayoutItem = | |
| 1259 (CXFA_ContainerLayoutItem*)pPageAreaLayoutItem->m_pFirstChild; | |
| 1260 pLayoutItem; | |
| 1261 pLayoutItem = (CXFA_ContainerLayoutItem*)pLayoutItem->m_pNextSibling) { | |
| 1262 if (pLayoutItem->m_pFormNode == pContentArea) { | |
| 1263 if (pLayoutItem->m_pFirstChild == NULL) { | |
| 1264 pContentAreaLayoutItem = pLayoutItem; | |
| 1265 return TRUE; | |
| 1266 } | |
| 1267 return FALSE; | |
| 1268 } | |
| 1269 } | |
| 1270 return TRUE; | |
| 1271 } | |
| 1272 FX_BOOL CXFA_LayoutPageMgr::GetNextContentArea(CXFA_Node* pContentArea) { | 1337 FX_BOOL CXFA_LayoutPageMgr::GetNextContentArea(CXFA_Node* pContentArea) { |
| 1273 CXFA_Node* pCurContentNode = | 1338 CXFA_Node* pCurContentNode = |
| 1274 GetCurrentContainerRecord()->pCurContentArea->m_pFormNode; | 1339 GetCurrentContainerRecord()->pCurContentArea->m_pFormNode; |
| 1275 if (pContentArea == NULL) { | 1340 if (pContentArea == NULL) { |
| 1276 pContentArea = | 1341 pContentArea = |
| 1277 pCurContentNode->GetNextSameClassSibling(XFA_ELEMENT_ContentArea); | 1342 pCurContentNode->GetNextSameClassSibling(XFA_ELEMENT_ContentArea); |
| 1278 if (pContentArea == NULL) { | 1343 if (pContentArea == NULL) { |
| 1279 return FALSE; | 1344 return FALSE; |
| 1280 } | 1345 } |
| 1281 } else { | 1346 } else { |
| 1282 if (pContentArea->GetNodeItem(XFA_NODEITEM_Parent) != m_pCurPageArea) { | 1347 if (pContentArea->GetNodeItem(XFA_NODEITEM_Parent) != m_pCurPageArea) { |
| 1283 return FALSE; | 1348 return FALSE; |
| 1284 } | 1349 } |
| 1285 CXFA_ContainerLayoutItem* pContentAreaLayout = NULL; | 1350 CXFA_ContainerLayoutItem* pContentAreaLayout = NULL; |
| 1286 if (!XFA_LayoutPageMgr_CheckContentAreaNotUsed( | 1351 if (!CheckContentAreaNotUsed(GetCurrentContainerRecord()->pCurPageArea, |
| 1287 GetCurrentContainerRecord()->pCurPageArea, pContentArea, | 1352 pContentArea, pContentAreaLayout)) { |
| 1288 pContentAreaLayout)) { | |
| 1289 return FALSE; | 1353 return FALSE; |
| 1290 } | 1354 } |
| 1291 if (pContentAreaLayout) { | 1355 if (pContentAreaLayout) { |
| 1292 if (pContentAreaLayout->m_pFormNode != pCurContentNode) { | 1356 if (pContentAreaLayout->m_pFormNode != pCurContentNode) { |
| 1293 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); | 1357 CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); |
| 1294 pNewRecord->pCurContentArea = pContentAreaLayout; | 1358 pNewRecord->pCurContentArea = pContentAreaLayout; |
| 1295 return TRUE; | 1359 return TRUE; |
| 1296 } else { | 1360 } else { |
| 1297 return FALSE; | 1361 return FALSE; |
| 1298 } | 1362 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 m_pCurPageArea = NULL; | 1552 m_pCurPageArea = NULL; |
| 1489 m_nCurPageCount = 0; | 1553 m_nCurPageCount = 0; |
| 1490 m_bCreateOverFlowPage = FALSE; | 1554 m_bCreateOverFlowPage = FALSE; |
| 1491 m_pPageSetMap.RemoveAll(); | 1555 m_pPageSetMap.RemoveAll(); |
| 1492 } | 1556 } |
| 1493 CXFA_LayoutItem* CXFA_LayoutPageMgr::FindOrCreateLayoutItem( | 1557 CXFA_LayoutItem* CXFA_LayoutPageMgr::FindOrCreateLayoutItem( |
| 1494 CXFA_Node* pFormNode) { | 1558 CXFA_Node* pFormNode) { |
| 1495 return pFormNode->GetDocument()->GetParser()->GetNotify()->OnCreateLayoutItem( | 1559 return pFormNode->GetDocument()->GetParser()->GetNotify()->OnCreateLayoutItem( |
| 1496 pFormNode); | 1560 pFormNode); |
| 1497 } | 1561 } |
| 1498 static void XFA_SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem, | 1562 |
| 1499 CXFA_FFNotify* pNotify, | |
| 1500 CXFA_LayoutProcessor* pDocLayout) { | |
| 1501 CXFA_LayoutItem* pNextLayoutItem; | |
| 1502 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; | |
| 1503 while (pCurLayoutItem) { | |
| 1504 pNextLayoutItem = pCurLayoutItem->m_pNextSibling; | |
| 1505 if (pCurLayoutItem->m_pFirstChild) { | |
| 1506 XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); | |
| 1507 } | |
| 1508 pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem); | |
| 1509 delete pCurLayoutItem; | |
| 1510 pCurLayoutItem = pNextLayoutItem; | |
| 1511 } | |
| 1512 } | |
| 1513 void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) { | 1563 void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) { |
| 1514 CXFA_LayoutItem* pNextLayoutItem; | 1564 CXFA_LayoutItem* pNextLayoutItem; |
| 1515 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; | 1565 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; |
| 1516 while (pCurLayoutItem) { | 1566 while (pCurLayoutItem) { |
| 1517 pNextLayoutItem = pCurLayoutItem->m_pNextSibling; | 1567 pNextLayoutItem = pCurLayoutItem->m_pNextSibling; |
| 1518 if (pCurLayoutItem->IsContentLayoutItem()) { | 1568 if (pCurLayoutItem->IsContentLayoutItem()) { |
| 1519 uint32_t dwFlag = pCurLayoutItem->m_pFormNode->GetFlag(); | 1569 uint32_t dwFlag = pCurLayoutItem->m_pFormNode->GetFlag(); |
| 1520 if (dwFlag & (XFA_NODEFLAG_HasRemoved)) { | 1570 if (dwFlag & (XFA_NODEFLAG_HasRemoved)) { |
| 1521 CXFA_FFNotify* pNotify = | 1571 CXFA_FFNotify* pNotify = |
| 1522 m_pTemplatePageSetRoot->GetDocument()->GetParser()->GetNotify(); | 1572 m_pTemplatePageSetRoot->GetDocument()->GetParser()->GetNotify(); |
| 1523 CXFA_LayoutProcessor* pDocLayout = | 1573 CXFA_LayoutProcessor* pDocLayout = |
| 1524 m_pTemplatePageSetRoot->GetDocument()->GetDocLayout(); | 1574 m_pTemplatePageSetRoot->GetDocument()->GetDocLayout(); |
| 1525 if (pCurLayoutItem->m_pFirstChild) { | 1575 if (pCurLayoutItem->m_pFirstChild) { |
| 1526 XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); | 1576 SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); |
| 1527 } | 1577 } |
| 1528 pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem); | 1578 pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem); |
| 1529 delete pCurLayoutItem; | 1579 delete pCurLayoutItem; |
| 1530 pCurLayoutItem = pNextLayoutItem; | 1580 pCurLayoutItem = pNextLayoutItem; |
| 1531 continue; | 1581 continue; |
| 1532 } | 1582 } |
| 1533 if (dwFlag & XFA_NODEFLAG_LayoutGeneratedNode) { | 1583 if (dwFlag & XFA_NODEFLAG_LayoutGeneratedNode) { |
| 1534 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> | 1584 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> |
| 1535 sIterator(pCurLayoutItem->m_pFormNode); | 1585 sIterator(pCurLayoutItem->m_pFormNode); |
| 1536 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; | 1586 for (CXFA_Node* pNode = sIterator.GetCurrent(); pNode; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1780 case XFA_ELEMENT_PageArea: | 1830 case XFA_ELEMENT_PageArea: |
| 1781 m_pLayoutProcessor->GetRootRootItemLayoutProcessor() | 1831 m_pLayoutProcessor->GetRootRootItemLayoutProcessor() |
| 1782 ->DoLayoutPageArea(pContainerItem); | 1832 ->DoLayoutPageArea(pContainerItem); |
| 1783 break; | 1833 break; |
| 1784 default: | 1834 default: |
| 1785 break; | 1835 break; |
| 1786 } | 1836 } |
| 1787 } | 1837 } |
| 1788 } | 1838 } |
| 1789 } | 1839 } |
| 1790 void XFA_SyncContainer(CXFA_FFNotify* pNotify, | 1840 |
| 1791 CXFA_LayoutProcessor* pDocLayout, | |
| 1792 CXFA_LayoutItem* pContainerItem, | |
| 1793 uint32_t dwRelevant, | |
| 1794 FX_BOOL bVisible, | |
| 1795 int32_t nPageIndex) { | |
| 1796 FX_BOOL bVisibleItem = FALSE; | |
| 1797 uint32_t dwStatus = 0; | |
| 1798 uint32_t dwRelevantContainer = 0; | |
| 1799 if (bVisible) { | |
| 1800 XFA_ATTRIBUTEENUM eAttributeValue = | |
| 1801 pContainerItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence); | |
| 1802 if (eAttributeValue == XFA_ATTRIBUTEENUM_Visible || | |
| 1803 eAttributeValue == XFA_ATTRIBUTEENUM_Unknown) { | |
| 1804 bVisibleItem = TRUE; | |
| 1805 } | |
| 1806 dwRelevantContainer = | |
| 1807 XFA_GetRelevant(pContainerItem->m_pFormNode, dwRelevant); | |
| 1808 dwStatus = | |
| 1809 (bVisibleItem ? XFA_LAYOUTSTATUS_Visible : 0) | dwRelevantContainer; | |
| 1810 } | |
| 1811 pNotify->OnLayoutItemAdded(pDocLayout, pContainerItem, nPageIndex, dwStatus); | |
| 1812 for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild; | |
| 1813 pChild = pChild->m_pNextSibling) { | |
| 1814 if (pChild->IsContentLayoutItem()) { | |
| 1815 XFA_SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer, | |
| 1816 bVisibleItem, nPageIndex); | |
| 1817 } | |
| 1818 } | |
| 1819 } | |
| 1820 void CXFA_LayoutPageMgr::SyncLayoutData() { | 1841 void CXFA_LayoutPageMgr::SyncLayoutData() { |
| 1821 MergePageSetContents(); | 1842 MergePageSetContents(); |
| 1822 LayoutPageSetContents(); | 1843 LayoutPageSetContents(); |
| 1823 CXFA_FFNotify* pNotify = | 1844 CXFA_FFNotify* pNotify = |
| 1824 m_pTemplatePageSetRoot->GetDocument()->GetParser()->GetNotify(); | 1845 m_pTemplatePageSetRoot->GetDocument()->GetParser()->GetNotify(); |
| 1825 int32_t nPageIdx = -1; | 1846 int32_t nPageIdx = -1; |
| 1826 CXFA_ContainerLayoutItem* pRootLayoutItem = GetRootLayoutItem(); | 1847 CXFA_ContainerLayoutItem* pRootLayoutItem = GetRootLayoutItem(); |
| 1827 for (; pRootLayoutItem; | 1848 for (; pRootLayoutItem; |
| 1828 pRootLayoutItem = | 1849 pRootLayoutItem = |
| 1829 (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling) { | 1850 (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling) { |
| 1830 CXFA_NodeIteratorTemplate< | 1851 CXFA_NodeIteratorTemplate< |
| 1831 CXFA_ContainerLayoutItem, | 1852 CXFA_ContainerLayoutItem, |
| 1832 CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> | 1853 CXFA_TraverseStrategy_ContentAreaContainerLayoutItem> |
| 1833 iteratorParent(pRootLayoutItem); | 1854 iteratorParent(pRootLayoutItem); |
| 1834 for (CXFA_ContainerLayoutItem* pContainerItem = iteratorParent.GetCurrent(); | 1855 for (CXFA_ContainerLayoutItem* pContainerItem = iteratorParent.GetCurrent(); |
| 1835 pContainerItem; pContainerItem = iteratorParent.MoveToNext()) { | 1856 pContainerItem; pContainerItem = iteratorParent.MoveToNext()) { |
| 1836 switch (pContainerItem->m_pFormNode->GetClassID()) { | 1857 switch (pContainerItem->m_pFormNode->GetClassID()) { |
| 1837 case XFA_ELEMENT_PageArea: { | 1858 case XFA_ELEMENT_PageArea: { |
| 1838 nPageIdx++; | 1859 nPageIdx++; |
| 1839 uint32_t dwRelevant = | 1860 uint32_t dwRelevant = |
| 1840 XFA_LAYOUTSTATUS_Viewable | XFA_LAYOUTSTATUS_Printable; | 1861 XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable; |
| 1841 CXFA_NodeIteratorTemplate<CXFA_LayoutItem, | 1862 CXFA_NodeIteratorTemplate<CXFA_LayoutItem, |
| 1842 CXFA_TraverseStrategy_LayoutItem> | 1863 CXFA_TraverseStrategy_LayoutItem> |
| 1843 iterator(pContainerItem); | 1864 iterator(pContainerItem); |
| 1844 CXFA_LayoutItem* pChildLayoutItem = iterator.GetCurrent(); | 1865 CXFA_LayoutItem* pChildLayoutItem = iterator.GetCurrent(); |
| 1845 while (pChildLayoutItem) { | 1866 while (pChildLayoutItem) { |
| 1846 CXFA_ContentLayoutItem* pContentItem = | 1867 CXFA_ContentLayoutItem* pContentItem = |
| 1847 pChildLayoutItem->AsContentLayoutItem(); | 1868 pChildLayoutItem->AsContentLayoutItem(); |
| 1848 if (!pContentItem) { | 1869 if (!pContentItem) { |
| 1849 pChildLayoutItem = iterator.MoveToNext(); | 1870 pChildLayoutItem = iterator.MoveToNext(); |
| 1850 continue; | 1871 continue; |
| 1851 } | 1872 } |
| 1852 FX_BOOL bVisible = | 1873 FX_BOOL bVisible = |
| 1853 (pContentItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence) == | 1874 (pContentItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence) == |
| 1854 XFA_ATTRIBUTEENUM_Visible); | 1875 XFA_ATTRIBUTEENUM_Visible); |
| 1855 uint32_t dwRelevantChild = | 1876 uint32_t dwRelevantChild = |
| 1856 XFA_GetRelevant(pContentItem->m_pFormNode, dwRelevant); | 1877 GetRelevant(pContentItem->m_pFormNode, dwRelevant); |
| 1857 XFA_SyncContainer(pNotify, m_pLayoutProcessor, pContentItem, | 1878 SyncContainer(pNotify, m_pLayoutProcessor, pContentItem, |
| 1858 dwRelevantChild, bVisible, nPageIdx); | 1879 dwRelevantChild, bVisible, nPageIdx); |
| 1859 pChildLayoutItem = iterator.SkipChildrenAndMoveToNext(); | 1880 pChildLayoutItem = iterator.SkipChildrenAndMoveToNext(); |
| 1860 } | 1881 } |
| 1861 } break; | 1882 } break; |
| 1862 default: | 1883 default: |
| 1863 break; | 1884 break; |
| 1864 } | 1885 } |
| 1865 } | 1886 } |
| 1866 } | 1887 } |
| 1867 int32_t nPage = m_PageArray.GetSize(); | 1888 int32_t nPage = m_PageArray.GetSize(); |
| 1868 for (int32_t i = nPage - 1; i >= m_nAvailPages; i--) { | 1889 for (int32_t i = nPage - 1; i >= m_nAvailPages; i--) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1917 } | 1938 } |
| 1918 pRootLayoutItem = m_pPageSetLayoutItemRoot; | 1939 pRootLayoutItem = m_pPageSetLayoutItemRoot; |
| 1919 CXFA_ContainerLayoutItem* pNextLayout = NULL; | 1940 CXFA_ContainerLayoutItem* pNextLayout = NULL; |
| 1920 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { | 1941 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { |
| 1921 pNextLayout = (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling; | 1942 pNextLayout = (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling; |
| 1922 SaveLayoutItem(pRootLayoutItem); | 1943 SaveLayoutItem(pRootLayoutItem); |
| 1923 delete pRootLayoutItem; | 1944 delete pRootLayoutItem; |
| 1924 } | 1945 } |
| 1925 m_pPageSetLayoutItemRoot = NULL; | 1946 m_pPageSetLayoutItemRoot = NULL; |
| 1926 } | 1947 } |
| OLD | NEW |