Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "sdpage.hxx"
31 : : #include "View.hxx"
32 : : #include "pres.hxx"
33 : :
34 : : namespace sd {
35 : :
36 : 0 : static bool implIsMultiPresObj( PresObjKind eKind )
37 : : {
38 [ # # ]: 0 : switch( eKind )
39 : : {
40 : : case PRESOBJ_OUTLINE:
41 : : case PRESOBJ_GRAPHIC:
42 : : case PRESOBJ_OBJECT:
43 : : case PRESOBJ_CHART:
44 : : case PRESOBJ_ORGCHART:
45 : : case PRESOBJ_TABLE:
46 : : case PRESOBJ_IMAGE:
47 : : case PRESOBJ_MEDIA:
48 : 0 : return true;
49 : : default:
50 : 0 : return false;
51 : : }
52 : : }
53 : :
54 : 0 : SdrObject* View::GetEmptyPresentationObject( PresObjKind eKind )
55 : : {
56 : 0 : SdrObject* pEmptyObj = 0;
57 : :
58 : 0 : SdrPageView* pPV = GetSdrPageView();
59 [ # # ]: 0 : if( pPV )
60 : : {
61 : 0 : SdPage* pPage = static_cast< SdPage* >( pPV->GetPage() );
62 [ # # ][ # # ]: 0 : if( pPage && !pPage->IsMasterPage() )
[ # # ]
63 : : {
64 : : // first try selected shape
65 [ # # ]: 0 : if ( AreObjectsMarked() )
66 : : {
67 : : /**********************************************************
68 : : * Is an empty graphic object available?
69 : : **********************************************************/
70 : 0 : const SdrMarkList& rMarkList = GetMarkedObjectList();
71 : :
72 [ # # ]: 0 : if (rMarkList.GetMarkCount() == 1)
73 : : {
74 : 0 : SdrMark* pMark = rMarkList.GetMark(0);
75 : 0 : SdrObject* pObj = pMark->GetMarkedSdrObj();
76 : :
77 [ # # ][ # # ]: 0 : if( pObj->IsEmptyPresObj() && implIsMultiPresObj( pPage->GetPresObjKind(pObj) ) )
[ # # ]
78 : 0 : pEmptyObj = pObj;
79 : : }
80 : : }
81 : :
82 : : // try to find empty pres obj of same type
83 [ # # ]: 0 : if( !pEmptyObj )
84 : : {
85 : 0 : int nIndex = 1;
86 [ # # ]: 0 : do
[ # # # # ]
87 : : {
88 : 0 : pEmptyObj = pPage->GetPresObj(eKind, nIndex++ );
89 : : }
90 : 0 : while( (pEmptyObj != 0) && (!pEmptyObj->IsEmptyPresObj()) );
91 : : }
92 : :
93 : : // last try to find empty pres obj of multiple type
94 [ # # ]: 0 : if( !pEmptyObj )
95 : : {
96 : 0 : const std::list< SdrObject* >& rShapes = pPage->GetPresentationShapeList().getList();
97 : :
98 [ # # ][ # # ]: 0 : for( std::list< SdrObject* >::const_iterator iter( rShapes.begin() ); iter != rShapes.end(); ++iter )
[ # # ]
99 : : {
100 [ # # ][ # # ]: 0 : if( (*iter)->IsEmptyPresObj() && implIsMultiPresObj(pPage->GetPresObjKind(*iter)) )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
101 : : {
102 [ # # ]: 0 : pEmptyObj = (*iter);
103 : 0 : break;
104 : : }
105 : : }
106 : : }
107 : : }
108 : : }
109 : :
110 : 0 : return pEmptyObj;
111 : : }
112 : :
113 : : }
114 : :
115 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|