merge the formfield patch from ooo-build
[ooovba.git] / sc / source / core / tool / charthelper.cxx
blobec0da7981bdf5ec837bd8503388afa503893fcd7
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: charthelper.cxx,v $
10 * $Revision: 1.1.2.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 #include "charthelper.hxx"
35 #include "document.hxx"
36 #include "drwlayer.hxx"
38 //#include <vcl/svapp.hxx>
39 #include <svx/svditer.hxx>
40 #include <svx/svdoole2.hxx>
41 #include <svx/svdpage.hxx>
44 using namespace com::sun::star;
45 using ::com::sun::star::uno::Reference;
46 using ::com::sun::star::uno::WeakReference;
50 // ====================================================================
52 namespace
56 USHORT lcl_DoUpdateCharts( const ScAddress& rPos, ScDocument* pDoc, BOOL bAllCharts )
58 ScDrawLayer* pModel = pDoc->GetDrawLayer();
59 if (!pModel)
60 return 0;
62 USHORT nFound = 0;
64 USHORT nPageCount = pModel->GetPageCount();
65 for (USHORT nPageNo=0; nPageNo<nPageCount; nPageNo++)
67 SdrPage* pPage = pModel->GetPage(nPageNo);
68 DBG_ASSERT(pPage,"Page ?");
70 SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
71 SdrObject* pObject = aIter.Next();
72 while (pObject)
74 if ( pObject->GetObjIdentifier() == OBJ_OLE2 && pDoc->IsChart( pObject ) )
76 String aName = ((SdrOle2Obj*)pObject)->GetPersistName();
77 BOOL bHit = TRUE;
78 if ( !bAllCharts )
80 ScRangeList aRanges;
81 BOOL bColHeaders = FALSE;
82 BOOL bRowHeaders = FALSE;
83 pDoc->GetOldChartParameters( aName, aRanges, bColHeaders, bRowHeaders );
84 bHit = aRanges.In( rPos );
86 if ( bHit )
88 pDoc->UpdateChart( aName );
89 ++nFound;
92 pObject = aIter.Next();
95 return nFound;
98 }//end anonymous namespace
100 // === ScChartHelper ======================================
102 //static
103 USHORT ScChartHelper::DoUpdateCharts( const ScAddress& rPos, ScDocument* pDoc )
105 return lcl_DoUpdateCharts( rPos, pDoc, FALSE );
108 //static
109 USHORT ScChartHelper::DoUpdateAllCharts( ScDocument* pDoc )
111 return lcl_DoUpdateCharts( ScAddress(), pDoc, TRUE );